<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<div class="easyui-layout" fit="true">
  <div region="center" style="padding:0px;border:0px">
  <t:datagrid name="deviceList" checkbox="false" fitColumns="true" title="科研设备展示" actionUrl="cms-device.do?console-datagrid" idField="id" fit="true" queryMode="group">
   <t:dgCol title="主键"  field="id"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="创建日期"  field="createDate" formatter="yyyy-MM-dd" hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="设备名称"  field="title"   query="true" queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="设备编号"  field="deviceNo"   query="false" queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="品牌"  field="brand"    queryMode="single"  width="120"></t:dgCol> 
   <t:dgCol title="型号名称"  field="deviceModel"     queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="排序"  field="sortOrder"    queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="是否发布"  field="isOnline"  query="true"   queryMode="single"  
   	width="120" formatterjs="function(v,rec){return v==1? '是':'否'}"
   	replace="已发布_1,未发布_0"
   	></t:dgCol>
   <t:dgCol title="删除"  field="deleted"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="操作" field="opt" width="150"></t:dgCol>
   <t:dgFunOpt  funname="setOnline(id)" title="发布" exp="isOnline#eq#0,null"/>
   <t:dgFunOpt  funname="setOffline(id)" title="下线" exp="isOnline#eq#1"/>
   <t:dgFunOpt  funname="editItemDetail({'编辑'},{'cms-device.do?goUpdate'},id,{'800'},{'500'})" title="编辑"  />
   <t:dgFunOpt  funname="showItemDetail({'查看'},{'cms-device.do?goUpdate'},id,{'800'},{'500'})" title="查看"  />
   <t:dgDelOpt title="删除" url="cms-device.do.do?doDel&id={id}" />  
   <t:dgToolBar title="录入" icon="icon-add" url="cms-device.do?goAdd" funname="add" height="500" width="800"></t:dgToolBar>
    
  </t:datagrid>
  </div>
 </div>
 <script type="text/javascript">
 $(document).ready(function(){
 		//给时间控件加上样式
 			$("#dictDeviceModelListtb").find("input[name='createDate']").attr("class","Wdate").click(function(){WdatePicker({dateFmt:'yyyy-MM-dd'});});
 });
 
 function setOffline(id,state){
	 setOnlineState(id,0);
}
 
function setOnlineState(id,state){
	$.ajax({
		url:"cms-device.do?setonline&id="+id+"&state="+state,
		success:function(data){
			data = $.parseJSON(data);
			if(data.success){
				tip("操作成功");
				reloadTable();
			}else{
				tip("操作失败！");
			}
		}
	});
}

function setOnline(id){
	setOnlineState(id,1);
}
 </script>
  